package com.clarence.dada.modular.system.menu.controller;

import com.clarence.dada.core.base.Result;
import com.clarence.dada.modular.system.menu.entity.req.SysMenuReq;
import com.clarence.dada.modular.system.menu.entity.resp.SysMenuDropDownTreeResp;
import com.clarence.dada.modular.system.menu.entity.resp.SysMenuResp;
import com.clarence.dada.modular.system.menu.entity.resp.SysMenuTreeResp;
import com.clarence.dada.modular.system.menu.service.SysMenuService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 系统菜单控制器
 *
 * @author GD
 * @since 2020/3/20 18:54
 */
@RestController
@RequestMapping("/system/sysMenu/")
@Tag(name = "菜单管理", description = "菜单管理Controller")
public class SysMenuController {

    @Resource
    private SysMenuService sysMenuService;

    /**
     * 添加系统菜单
     *
     * @author GD
     * @since 2020/3/27 8:57
     */
    @Operation(summary = "系统菜单_新增", description = "新增菜单")
    @PostMapping("menuAdd")
    public Result<Void> menuAdd(@RequestBody @Validated(SysMenuReq.add.class) SysMenuReq req) {
        sysMenuService.menuAdd(req);
        return Result.SUCCESS;
    }

    /**
     * 编辑系统菜单
     *
     * @author GD
     * @since 2020/3/27 8:59
     */
    @Operation(summary = "系统菜单_编辑", description = "编辑菜单")
    @PostMapping("menuEdit")
    public Result<Void> menuEdit(@RequestBody @Validated(SysMenuReq.edit.class) SysMenuReq req) {
        sysMenuService.menuEdit(req);
        return Result.SUCCESS;
    }

    /**
     * 查看系统菜单
     *
     * @author GD
     * @since 2020/3/27 9:01
     */
    @Operation(summary = "系统菜单_查看", description = "查看菜单详情")
    @GetMapping("menuDetail")
    public Result<SysMenuResp> menuDetail(@Validated(SysMenuReq.detail.class) SysMenuReq req) {
        return new Result<>(sysMenuService.menuDetail(req));
    }

    /**
     * 删除系统菜单
     *
     * @author GD
     * @since 2020/3/27 8:58
     */
    @Operation(summary = "系统菜单_删除", description = "删除菜单")
    @PostMapping("menuDelete")
    public Result<Void> menuDelete(@RequestBody @Validated(SysMenuReq.delete.class) SysMenuReq req) {
        sysMenuService.menuDelete(req);
        return Result.SUCCESS;
    }
//
//    /**
//     * 获取系统左侧菜单（适用于登录后获取左侧菜单）
//     *
//     * @author majianguo
//     * @since 2021/1/7 15:17
//     */
//    @Operation(summary = "系统菜单_所有菜单", description = "获取系统所有菜单（适用于登录后获取左侧菜单）")
//    @PostMapping("leftMenuList")
//    public Result<List<SysMenuTreeResp>> getLeftMenuList(SysMenuReq req) {
//        return new Result<>(sysMenuService.getLeftMenuList(req));
//    }

    /**
     * 菜单列表，带树形结构（菜单管理界面的列表用）
     *
     * @author GD
     * @since 2020/3/20 21:23
     */
    @Operation(summary = "系统菜单_列表（树）", description = "系统菜单列表（树）")
    @GetMapping("menuListTree")
    public Result<List<SysMenuTreeResp>> menuListTree(SysMenuReq req) {
        return new Result<>(sysMenuService.menuListTree(req));
    }

    /**
     * 获取系统菜单树，用于新增，编辑时选择上级节点（用在新增和编辑菜单选择上级菜单）
     *
     * @author GD
     * @since 2020/3/27 15:55
     */
    @Operation(summary = "系统菜单_列表（下拉树）", description = "获取系统菜单树，用于新增，编辑时选择上级节点")
    @GetMapping("menuDropDownTree")
    public Result<List<SysMenuDropDownTreeResp>> menuDropDownTree(SysMenuReq req) {
        return new Result<>(sysMenuService.menuDropDownTree(req));
    }
//
//    /**
//     * 新版角色分配菜单和按钮界面使用的接口
//     *
//     * @author GD
//     * @since 2021/8/10 22:21
//     */
//    @Operation(summary = "系统菜单_角色分配", description = "角色分配菜单和按钮界面使用的接口（v2）")
//    @PostMapping("menuAndButtonTreeChildren")
//    public Result<List<MenuAndButtonTreeResponse>> menuAndButtonTreeChildrenV2(SysMenuReq req) {
//        List<MenuAndButtonTreeResponse> treeResponseList = menuServiceApi.getRoleMenuAndButtons(req);
//        return new Result<>(treeResponseList);
//    }

}
